'use strict';
var Schema = require('mongoose').Schema,
    Model = require('../../../Base/server/controllers/Model');

var modelField = {
    // Org: {
    //     type: Schema.ObjectId,
    //     Name: '组织',
    //     ref: 'Org'        
    // },
	ItemMaster: {
	    type: Schema.ObjectId,
	    ref: 'ItemMaster',
	    Name: '料品',
	    IsEmpty: false
	},
	Department: {
        type: Schema.ObjectId,
        Name: '部门',
        ref: 'Department'
    },
    BizDate: {
	    type: Date,
	    Name: '流水日期',
	    IsEmpty: false
	},
	BOH: {
	    type: Number,
	    Name: '期初库存',
	    default: 0
	},
	BWIP: {
	    type: Number,
	    Name: '期初在制',
	    default: 0
	},
	EWIP: {
	    type: Number,
	    Name: '期末在制',
	    default: 0
	},
	EOH: {
	    type: Number,
	    Name: '期末库存',
	    default: 0
	},
    TransInQty: {
	    type: Number,
	    Name: '当期转入',
	    default: 0
	},
	CompleteQty: {
	    type: Number,
	    Name: '当期完工',
	    default: 0
	},
	ReworkQty: {
	    type: Number,
	    Name: '当期返工',
	    default: 0
	},
	ScriptQty: {
	    type: Number,
	    Name: '当期报废',
	    default: 0
	},
	RcvQty: {
	    type: Number,
	    Name: '当期入库',
	    default: 0
	},
	TransOutQty: {
	    type: Number,
	    Name: '当期转出',
	    default: 0
	},
	DescSeg1: {
	    type: String,
	    default: '',
	    trim: true,
	    Name: '扩展字段1'
	},
	DescSeg2: {
	    type: String,
	    default: '',
	    trim: true,
	    Name: '扩展字段2'
	},
	DescSeg3: {
	    type: String,
	    default: '',
	    trim: true,
	    Name: '扩展字段3'
	}
};

var newModel = new Model(modelField);
newModel.addIndex({ItemMaster: 1, Department: 1, BizDate: 1, DescSeg1: 1, DescSeg2: 1, DescSeg3: 1}, {"unique": true});
newModel.create('PeriodOutput', '期间产量');